<?php


namespace app\index\controller;
use think\Controller;

class Apitest extends Controller
{
    public function index()
    {
        $name = input('post.name');
        $encodeName = urlencode($name);
        $url = "http://api.91cha.com/index?key=fa3ebdbc2dac4232add346c4b2171e56&kws=$encodeName";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $result = curl_exec($ch);
        $data = json_decode($result,true);
//        halt($data);
        $value = $data['data'];
        foreach ($value as $k=>$v)
        {
            $aaa = $v['mobileindex'].PHP_EOL;
            $b = $v['so360index'] * 0.7;
        }
        $c = [$aaa,$b];
        halt($c);
        //curl_close($ch);
    }

}